package com.woniuxy.amusementparkos.service.lzw.impl;

import com.woniuxy.amusementparkos.dao.lzw.ShiftExchangeInfoDao;
import com.woniuxy.amusementparkos.entity.lzw.ShiftExchangeInfo;
import com.woniuxy.amusementparkos.service.lzw.ShiftExchangeInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ShiftExchangeInfo)表服务实现类
 *
 * @author makejava
 * @since 2020-04-27 21:00:43
 */
@Transactional
@Service("shiftExchangeInfoService")
public class ShiftExchangeInfoServiceImpl implements ShiftExchangeInfoService {
    @Resource
    private ShiftExchangeInfoDao shiftExchangeInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param shiftExchangeId 主键
     * @return 实例对象
     */
    @Override
    public ShiftExchangeInfo getById(Integer shiftExchangeId) {
        return this.shiftExchangeInfoDao.getById(shiftExchangeId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ShiftExchangeInfo> listAllByLimit(int offset, int limit) {
        return this.shiftExchangeInfoDao.listAllByLimit(offset, limit);
    }

    /**
     * 查询全部
     *
     * @return
     */
    @Override
    public List<ShiftExchangeInfo> listAll() {
        // mull:无参数判断，进行全部查询
        return this.shiftExchangeInfoDao.listAll(null);
    }

    /**
     * 新增数据
     *
     * @param shiftExchangeInfo 实例对象
     * @return 实例对象
     */
    @Override
    public ShiftExchangeInfo insert(ShiftExchangeInfo shiftExchangeInfo) {
        this.shiftExchangeInfoDao.insert(shiftExchangeInfo);
        return shiftExchangeInfo;
    }

    /**
     * 修改数据
     *
     * @param shiftExchangeInfo 实例对象
     * @return 实例对象
     */
    @Override
    public ShiftExchangeInfo update(ShiftExchangeInfo shiftExchangeInfo) {
        this.shiftExchangeInfoDao.update(shiftExchangeInfo);
        return this.getById(shiftExchangeInfo.getShiftExchangeId());
    }

    /**
     * 通过主键删除数据
     *
     * @param shiftExchangeId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer shiftExchangeId) {
        return this.shiftExchangeInfoDao.deleteById(shiftExchangeId) > 0;
    }
}